package com.linx.system.controller.system;

import com.linx.common.core.domain.R;
import com.linx.common.mybatis.helper.ParkHelper;
import com.linx.common.web.core.BaseController;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 园区管理
 *
 * @author Michelle.Chung
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/park")
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
public class SysParkController extends BaseController {
    /**
     * 动态切换租户
     *
     * @param parkInfoId 园区ID
     */
    //@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
    @GetMapping("/dynamic/{parkInfoId}")
    public R<Void> dynamicPark(@NotBlank(message = "园区id不能为空") @PathVariable String parkInfoId) {
        ParkHelper.setDynamic(parkInfoId, true);
        return R.ok();
    }

    /**
     * 清除动态租户
     */
    //@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
    @GetMapping("/dynamic/clear")
    public R<Void> dynamicClear() {
        ParkHelper.clearDynamic();
        return R.ok();
    }

}
